package dev.ece.core.sprite;

import java.util.Vector;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import dev.ece.core.cells.Cell;
import dev.ece.core.cells.alpha.Alpha;
import dev.ece.core.cells.decal.Decal;
import dev.ece.core.cells.shadow.Shadow;
import dev.ece.core.clearup.ClearUpGLRubbishManager;
import dev.ece.util.tools.transformations.Transformation;

public abstract class AbstractSprite implements Cell {
	
	protected final Logger log = LogManager.getLogger(AbstractSprite.class);
	
	private boolean visible = true;
	
	private boolean logic = true;
	
	private boolean initialized;
	
	private boolean decal;
	
	private boolean shadow;
	
	private boolean alpha;
	
	public final Vector<Transformation> transformations = new Vector<Transformation>();

	public AbstractSprite() {
		this.decal = this instanceof Decal;
		this.shadow = this instanceof Shadow;
		this.alpha = this instanceof Alpha;
	}
	
	/**
	 * 是否渲染普通物体
	 * @return
	 */
	public abstract boolean isNormalRender();
	
	/**
	 * 是否渲染透明物体
	 * @return
	 */
	public boolean isAlphaRender() {
		return this.alpha;
	}
	
	public boolean isDecalRender() {
		return decal;
	}
	
	public boolean isShadowRender() {
		return shadow;
	}
	
	@Override
	public Vector<Transformation> getTransformations() {
		return transformations;
	}

	@Override
	public boolean isInitialized() {
		return initialized;
	}

	@Override
	public void setInitialized(boolean initialized) {
		this.initialized = initialized;
	}

	@Override
	public boolean isVisible() {
		return visible;
	}

	@Override
	public boolean isLogic() {
		return logic;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	public void setLogic(boolean logic) {
		this.logic = logic;
	}

	@Override
	public void destroy() {
		this.setLogic(false);
		this.setVisible(false);
		transformations.clear();
		ClearUpGLRubbishManager.push(this);
	}

	@Override
	public boolean equals(Object obj) {
		return this == obj;
	}
	
}
